// load_sdk.js carga el sdk para la página de login

var acces_token;
var app = '442695465791609';
//var app = '319686771467594';

function login() {
    FB.login(function(response) {
        if (response.authResponse) {
            acces_token = response.authResponse.accessToken;
            exchangeToken(acces_token);
            obtieneDatos(acces_token);
        } else {
            alert("A cancelado el login");
        }
    },
            {scope: 'user_about_me,user_activities,user_birthday,user_interests,user_likes,user_location,publish_stream,read_stream,create_note,read_friendlists,manage_friendlists,email'});
}

window.fbAsyncInit = function() {
    
    FB.init({      
        appId: app, // App ID
        //channelUrl : '//localhost/facebooktest', // Channel File
        status: false, // check login status
        cookie: true, // enable cookies to allow the server to access the session
        xfbml: true, // parse XFBML
        oauth: true
    });

    //FB.getLoginStatus(statusChange);    
    //authUser();
    //getStat();

};


// Load the SDK Asynchronously
//(function(d){
//    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
//    if (d.getElementById(id)) {
//        return;
//    }
//    js = d.createElement('script');
//    js.id = id;
//    js.async = true;
//    js.src = "//connect.facebook.net/en_US/all.js";
//    ref.parentNode.insertBefore(js, ref);
//}(document));	
(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {
        return;
    }
    js = d.createElement(s);
    js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));